﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;
using Entities;

namespace DAL
{
    public class Tinh_ThanhPhoDAL
    {
        public static List<Tinh_ThanhPho> LayTatCa()
        {
            try
            {
                return CBO.FillCollection<Tinh_ThanhPho>(DataProvider.Instance.ExecuteReader("Tinh_ThanhPho_LayTatCa"));
            }
            catch
            {

                return new List<Tinh_ThanhPho>();
            }
        }
        public static Tinh_ThanhPho LayID(string IdTinh_ThanhPho)
        {
            try
            {
                return CBO.FillObject<Tinh_ThanhPho>(DataProvider.Instance.ExecuteReader("Tinh_ThanhPho_LayID", Convert.ToInt32(IdTinh_ThanhPho)));
            }
            catch
            {
                return null;
            }
        }
        public static bool Them(Tinh_ThanhPho tt)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQueryWithOutput("@IDTinh", "Tinh_ThanhPho_Them", tt.IDTinhTP, tt.TenTinhTP, tt.MoTa);
                return Convert.ToInt32(rs) > 0;

            }
            catch
            {

                return false;
            }
        }
        public static bool Sua(Tinh_ThanhPho tt)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("Tinh_ThanhPho_Sua", tt.IDTinhTP, tt.TenTinhTP, tt.MoTa);
                return Convert.ToInt32(rs) > 0;

            }
            catch
            {

                return false;
            }
        }
        public static bool Xoa(string ID)
        {
            try
            {
                int rs = DataProvider.Instance.ExecuteNonQuery("Tinh_ThanhPho_Xoa", Convert.ToInt32(ID));
                return Convert.ToInt32(rs) > 0;

            }
            catch
            {

                return false;
            }
        }

    }
}
